package com.zm.service.impl;

import com.zm.dao.AppVersionMapper;
import com.zm.pojo.AppVersion;
import com.zm.service.AppVersionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**最新版本业务实现类
 * Created by Administrator on 2018/9/17.
 */
@Service
public class AppVersionServiceImpl implements AppVersionService {
    @Resource
    private AppVersionMapper mapper;
    /**
     * 根据最新版本ID查询最新版本信息
     *
     * @param _id
     * @return
     */
    @Override
    public AppVersion selectById(String _id) {
        Long id=0l;
        if (_id!=null){
            id=Long.parseLong(_id);
        }
        AppVersion appVersion=mapper.selectByPrimaryKey(id);
        return appVersion;
    }

    /**
     * 动态增加版本信息
     *
     * @param appVersion
     * @return
     */
    @Override
    public boolean addVersion(AppVersion appVersion) {
        int i=mapper.insertSelective(appVersion);
        if (i>0){
            return true;
        }
        return false;
    }

    /**
     * 查询历史版本信息
     *
     * @return
     */
    @Override
    public List<AppVersion> selectBefore() {
        return mapper.selectHistoryVersion();
    }
}
